﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StockholmsStad.Web.UI.Class.Utilities;

namespace StockholmsStad.Web.UI.Test
{
    /// <summary>
    ///This is a test class for DictionarySessionAdapterTest and is intended
    ///to contain all DictionarySessionAdapterTest Unit Tests
    ///</summary>
    [TestClass]
    public class DictionarySessionAdapterTest
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes

        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion

        /// <summary>
        ///A test for Item
        ///</summary>
        [TestMethod]
        public void ItemTest()
        {
            var session = new Dictionary<string, object>();
            var target = new DictionarySessionAdapter(session);
            string key = "gurka";
            object expected = "citrus";
            object actual;
            target[key] = expected;
            actual = target[key];
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ContainsKey
        ///</summary>
        [TestMethod]
        public void ContainsKeyTest()
        {
            var session = new Dictionary<string, object>();
            var target = new DictionarySessionAdapter(session);
            string key = "gurka";
            object expected = true;
            object actual;
            target[key] = "kalle";
            actual = target.ContainsKey("gurka");
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ContainsKey
        ///</summary>
        [TestMethod]
        public void ContainsKeyTest2()
        {
            var session = new Dictionary<string, object>();
            var target = new DictionarySessionAdapter(session);
            string key = "gurka";
            object expected = false;
            object actual;
            target[key] = "Kalle";
            actual = target.ContainsKey("citron");
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Abandon
        ///</summary>
        [TestMethod]
        public void AbandonTest()
        {
            var session = new Dictionary<string, object>();
            var target = new DictionarySessionAdapter(session);
            string key = "gurka";
            target[key] = "Kalle";
            Assert.IsTrue(target.ContainsKey("gurka"));
            target.Abandon();
            Assert.IsFalse(target.ContainsKey("gurka"));
        }

        /// <summary>
        ///A test for DictionarySessionAdapter Constructor
        ///</summary>
        [TestMethod]
        public void DictionarySessionAdapterConstructorTest()
        {
            var session = new Dictionary<string, object>();
            var target = new DictionarySessionAdapter(session);
            Assert.IsNotNull(target);
        }
    }
}